<script type="text/javascript">     
$(document).ready(function(){

    // check for first change in form
    <? if($this->input->post("submit_action")!==FALSE){ ?>
        var hasChanged = true;                 
    <? } else { ?>
        var hasChanged = false;                
        $("input:submit").addClass("disabled");
    <? } ?>
    $("input,textarea").live("change", function(){
        if(hasChanged == false){
            hasChanged = true;
            $("input:submit").removeClass("disabled");
        }
    });

    //cancel button
    $(".cancel").click(function(){
        if (hasChanged != false)
            if (!confirm("If you leave this page now, you will loose the changes you've just made.\n\nProceed anyway?\n")) return false;
            window.location.href='<?=site_url("admin/faq")?>';
        return false;
    });
  
                  
});  
       
</script>

<div id="content">

<? if($this->input->post("submit_action") !== FALSE){ ?>
    <div class="response"><?=validation_errors()?></div>                
<? } ?>

    <form action="" method="post" id="faq_form">

    <div class="float_block_right">
        <a href="#" class="button cancel">CANCEL</a>
        <a href="<?=site_url('admin/faq/preview')?>" class="button" rel="preview">PREVIEW</a>
        <input type="submit" class="button " value="SAVE CHANGES">  
    </div>



    <? if ($action=='update') { ?>
        <h1>Edit FAQ</h1>
    <? } else { ?>
        <h1>Add New FAQ</h1>
    <? } ?>
                
    <div class="content_block">
        <h4>Title</h4>
        <input name="title" type="text" class="text_input" maxlength="250" value="<?=set_value('title', $item['Title_FAQs'])?>" />
    </div>

    <div class="content_block">
        <h4>Description</h4>
        <textarea name="description" class="tinymceEditor_force_paragraph"><?=set_value('description', $item['Description_FAQs'])?></textarea>
    </div>           
               
    <input type="hidden" name="submit_action" value="<?=$action?>" />
    <input type="hidden" name="id" value="<?=$item['id_FAQs']?>" />
    <input type="hidden" name="token" value="<?=$token?>" />

    <div class="float_block_right">
        <a href="#" class="button cancel">CANCEL</a>
        <a href="<?=site_url('admin/faq/preview')?>" class="button" rel="preview">PREVIEW</a>
        <input type="submit" class="button " value="SAVE CHANGES">  
    </div>

    </form>

</div>